//$Id: mainwindow.cc,v 1.2 2004/03/28 09:16:45 murrayc Exp $ -*- c++ -*-

/* gtkmm example Copyright (C) 2002 gtkmm development team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include "MainWindow.h"
#include <iostream>

MainWindow::MainWindow()
:
  m_Label("fcitx+ testing")
	,shape_image(NULL)
{
  set_title("Label");
  set_border_width(5);

  set_default_size(300,48);
  set_keep_above(true);
  set_skip_pager_hint();
  set_app_paintable(true);
  set_skip_taskbar_hint();
  set_decorated(false);

  //add(m_HBox);
  add(m_Fixed);

  //m_HBox.pack_start(m_Label, Gtk::PACK_SHRINK);
  m_Fixed.put(m_Label, 10,2);

#if 1

	Glib::RefPtr<Gdk::Screen> screen;
	Glib::RefPtr<Gdk::Colormap> colormap;
	screen=this->get_screen();
	colormap = screen->get_rgba_colormap();
	screen->set_default_colormap(colormap);
#endif
  //show_all_children();
  show_all();
}

MainWindow::~MainWindow()
{
}

void MainWindow::set_shape(const char* filename)
{
	shape_image = cairo_image_surface_create_from_png(filename);
}

#if 1
bool MainWindow::on_expose_event(GdkEventExpose* ev)
{
	cairo_t *cr;

	cr = gdk_cairo_create(this->get_window()->gobj());
	cairo_set_source_surface(cr, shape_image, 0, 0);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_paint(cr);
	cairo_destroy(cr);
	return false;
}

#endif

int main(int argc, char *argv[])
{
	Gtk::Main kit(argc, argv);
	MainWindow win;

	win.set_shape("./background.png");
	kit.run(win);
 

	return 0;
}
